package org.thirdHero.core.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateRange{
    private Date beginDate;
    private Date endDate;
    private String flagDate;

    public DateRange(Date beginDate, Date endDate, String flagDate) {
        this.beginDate = beginDate;
        this.endDate = endDate;
        this.flagDate = flagDate;
    }
    public DateRange(String beginDateStr,String endDateStr) throws ParseException {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
        try {
            this.beginDate = formatter.parse(beginDateStr+" 00:00:00 000");
            this.endDate = formatter.parse(endDateStr+" 23:59:59 000");
        } catch (Exception e) {
           DateRange nowDate =  DateHelper.getToday();
            this.beginDate = nowDate.getBeginDate();
            this.endDate = nowDate.getEndDate();
        }
    }

    @Override
    public String toString() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
        return "DateRange{" +
                "beginDate=" + formatter.format(beginDate) +
                ", endDate=" + formatter.format(endDate) +
                ", flagDate='" + flagDate + '\'' +
                '}';
    }

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getFlagDate() {
        return flagDate;
    }

    public void setFlagDate(String flagDate) {
        this.flagDate = flagDate;
    }
}
